import React, { Component, useState } from 'react'
import { useFn } from './utils/xxx'
export default function Registe() {
  // const [username, setUsername] = useState('')
  // const [password, setPassword] = useState('')
  // const [repassword, setRePassword] = useState('')
  // const handle = (name) => (e) => {
  //   if (name === 'username') {
  //     setUsername(e.target.value.trim())
  //   } else if (name === 'password') {
  //     setPassword(e.target.value.trim())
  //   } else {
  //     setRePassword(e.target.value.trim())
  //   }
  // }
  const { username, password, repassword, handle } = useFn()
  return (
    <form>
      用户名:
      <input type="text" value={username} onChange={handle('username')} />
      <br />
      密码:
      <input
        type="password"
        autoComplete="true"
        value={password}
        onChange={handle('password')}
      />
      <br />
      确认密码:
      <input
        type="password"
        autoComplete="true"
        value={repassword}
        onChange={handle('repassword')}
      />
      <br />
      <button>注册</button>
    </form>
  )
}
